import { createRouter, createWebHashHistory } from 'vue-router'
import { LoginRoute, HttpErrorPage, ErrorPageRoute, ContentPageRoute } from '@/router/base'
import { createRouterGuards } from '@/router/router-guards'
import { DataDetailPage, EquipmentDetailPage, EquipmentParamPage } from '@/router/module/index.js'
import { EquipmentPage } from '@/router/module/equipment/index.js'
import { HistoryPage } from '@/router/module/history/index.js'
// layout 布局
const RootRoutes = [
	{
		// layout
		path: '/',
		name: 'Root',
		component: () => import('@/layout/tabLayout.vue'),
		children: [...HttpErrorPage, ...ContentPageRoute]
	},
	{
		path: '/maps',
		name: 'Maps',
		component: () => import('@/views/index/maps.vue')
	},
	{
		path: '/map',
		name: 'Map',
		component: () => import('@/views/index/map.vue')
	},
	{
		path: '/videos',
		name: 'Videos',
		component: () => import('@/views/index/videos.vue')
	},
	{
		path: '/videos',
		name: 'Videos',
		component: () => import('@/views/index/videos.vue')
	},
	{
		path: '/setting',
		name: 'setting',
		component: () => import('@/views/setting.vue')
	}
]
export const constantRouter = [
	LoginRoute,
	...HistoryPage,
	...RootRoutes,
	ErrorPageRoute,
	...DataDetailPage,
	...EquipmentDetailPage,
	...EquipmentPage
]
const router = createRouter({
	history: createWebHashHistory(),
	routes: constantRouter,
	strict: true
})

export function setupRouter(app) {
	app.use(router)
	// 创建路由守卫
	createRouterGuards(router)
}
export default router
